<%@ include file="/WEB-INF/views/taglib.jsp"%>
<spring:url var="banner" value="/resources/images/comfort/Logo_ComfortDelgro.png" />
<div class="loginWrapper">
<h1>E-Centre @ Redhill</h1>
<h3 align="center">Attendance - Clock In / Out</h3>
<div id="digitalTime">Loading time ...</div>
<form:form id="form" method="post" modelAttribute="attendance" cssClass="loginForm" >
<label for="nric">NRIC</label> <br />
<form:input id="nric" path="systemUser.nric" size="20" maxlength="50" /> <br /><br />
<label for="technicianName">Person Name
<c:if test="${attendance.systemUser.personName != null }">
 - <a href="javascript:openCenteredWindow('<c:url value="/user/updateAdHoc/${attendance.systemUser.userName}" />')">Click here to edit</a>
</c:if>
</label>
<br />
<h2><span id="technicianName">
	${attendance.systemUser.personName} <br />
	<c:if test="${attendance.systemUser.personName != null }">
 	 work in: ${attendance.systemUser.department.departmentName} <br />
 	 mobile: ${attendance.systemUser.contactInfo.mobileNo}  <br />
 	</c:if>
</span></h2>
		<spring:bind path="*">
			<c:choose>
			<c:when test="${status.error}">
 			<c:choose>
 				<c:when test="${not empty status.errors.globalErrors}">
 				<div id="message" class="error">
		  		<span class="ui-icon ui-icon-circle-close left marginright5"></span>
		  		<ul>
		  		<c:forEach items="${status.errors.globalErrors}" var="error">
		  		<li><spring:message code="${error.code}" arguments="${error.arguments}" /></li>
		  		</c:forEach>
		  		</ul>
			  	</div>	
 				</c:when>
 			</c:choose>
 			</c:when>
 			<c:when test="${not empty message}">
	 
			<div id="message" class="success">
				<span class="ui-icon ui-icon-circle-check left marginright5"></span>
				${message.text}
			</div>	
  			</c:when>
 			<c:otherwise>
 				<div class="error">Please scan your NRIC</div>		
 			</c:otherwise>
			</c:choose>
 			
 		</spring:bind>
 		
	
	

</form:form> 

</div>
<script type="text/javascript">
	$(document).ready(function() {
		
		setInterval(updateCurrentTime,2000);

		$('#nric').focus();
		
		$('input').keypress(function(e) {
	        if(e.which == 13) {
	            $(this).blur();
	            $('#form').submit();
	        }
	    });
		
	
		<c:if test="${validateFlag == 'false'}">
			openDialogWindow('<c:url value="/user/createAdHoc" />');
		</c:if>
		
		<c:if test="${not empty message}">	
			$('#message').fadeOut(60000,function(){
				$('#workOrderCode').val('');
				$('#nric').val('');
				$('#technicianName').text('');
				$('#message').text('Please scan your NRIC');
				$('#message').removeClass();
				$('#message').addClass('error');
				$('#message').show(2000);
			});
			
		</c:if>
	});
	
	function updateCurrentTime()
	{
		$('#digitalTime').load('<c:url value="/ajax/currentTime"></c:url>');
	}
	
	function openCenteredWindow(url) {
	    var width = 800;
	    var height = 500;
	    var left = parseInt((screen.availWidth/2) - (width/2));
	    var top = parseInt((screen.availHeight/2) - (height/2));
	    var windowFeatures = "width=" + width + ",height=" + height + ",status=0,menubar=0,resizable=0,toolbar=0,scrollbars=1,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
	    window.open(url, "subWind", windowFeatures);
	}
	
	function openDialogWindow(url) {
	    var width = "800px";
	    var height = "400px";
	    var windowFeatures = "dialogWidth=" + width + ";dialogHeight=" + height + ";center=1";
	    window.showModalDialog(url, "subWind2", windowFeatures);
	}
</script>		
